package org.testis.services;


/**
 * An abstract class to define a module action
 * All actions related to modules extends this clas.
 * Chain Of Responsibility pattern used to create
 * linked actions.
 * @author nurhat
 */
public abstract class AtofModuleAction
{

    protected AtofModuleAction m_successor;


    public void setSuccessor(AtofModuleAction successor)
    {
        this.m_successor = successor;
    }


    /**
     * Execute action and operate next step with m_successor if any
     * @param request
     * @return
     */
    public boolean processRequest(AtofModuleService request)
    {
        boolean result = operateRequest(request);
        if (m_successor != null) {
            result = result & m_successor.processRequest(
                request);
        }
        return result;
    }


    /**
     * Action is executed over this function
     * @param request
     * @return
     */
    abstract public boolean operateRequest(AtofModuleService request);
}
